package com.ecoolex.chinadutyfree.retailer.ws;

import java.util.List;

import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import com.ecoolex.chinadutyfree.retailer.core.manager.DirectMailGoodsManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.GoodsAfterServiceManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.GoodsBarcodeManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.GoodsBrandManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.GoodsCategoryManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.GoodsCategoryMarketingManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.GoodsManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.GoodsProductManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.GoodsShopwindowManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.GoodsSpecGroupManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.GoodsSpecManager;
import com.ecoolex.chinadutyfree.retailer.entity.GoodsAfterService;
import com.ecoolex.chinadutyfree.retailer.entity.GoodsBarcode;
import com.ecoolex.chinadutyfree.retailer.entity.GoodsBrand;
import com.ecoolex.chinadutyfree.retailer.entity.GoodsCategory;
import com.ecoolex.chinadutyfree.retailer.entity.GoodsCategoryMarketing;
import com.ecoolex.chinadutyfree.retailer.entity.GoodsProduct;
import com.ecoolex.chinadutyfree.retailer.entity.GoodsShopwindow;
import com.ecoolex.chinadutyfree.retailer.entity.GoodsSpec;
import com.ecoolex.chinadutyfree.retailer.entity.GoodsSpecGroup;
import com.ecoolex.chinadutyfree.retailer.entity.GoodsWithBLOBs;
import com.ecoolex.chinadutyfree.retailer.pojo.EditSpecGroupDTO;
import com.ecoolex.chinadutyfree.retailer.pojo.GoodsCategoryTopChildDO;
import com.ecoolex.chinadutyfree.retailer.pojo.QueryGoodsCategoryDTO;
import com.ecoolex.chinadutyfree.retailer.pojo.QueryGoodsDTO;
import com.ecoolex.framework.common.exception.BizException;
import com.ecoolex.framework.common.pojo.Page;
import com.ecoolex.framework.common.pojo.Pagination;
import com.ecoolex.framework.common.pojo.Sorting;


@Service
public class GoodsServiceImpl implements GoodsService {

	@Autowired
	private GoodsBrandManager goodsBrandManager;

	@Override
	public GoodsBrand addBrand(GoodsBrand record, String createUser) {
		return goodsBrandManager.add(record, createUser);
	}

	@Override
	public GoodsBrand updateBrand(GoodsBrand record, String updateUser) {
		return goodsBrandManager.update(record, updateUser);
	}

	@Override
	public void deleteBrand(GoodsBrand record, String updateUser) {
		goodsBrandManager.delete(record, updateUser);
	}

	@Override
	public GoodsBrand getBrandById(Integer brandId) {
		return goodsBrandManager.getById(brandId);
	}

	@Override
	public Pagination<GoodsBrand> queryBrand(String name, Integer categoryId, Sorting[] sorts, Page page) {
		return goodsBrandManager.query(name, categoryId, sorts, page);
	}
	
	@Override
	public Pagination<GoodsBrand> queryBrandForH5(String name, Page page) {
		return goodsBrandManager.queryBrandForH5(name, page);
	}

	@Autowired
	private GoodsCategoryManager goodsCategoryManager;

	@Override
	public GoodsCategory addCategory(GoodsCategory record, String createUser) {
		return goodsCategoryManager.add(record, createUser);
	}

	@Override
	public GoodsCategory updateCategory(GoodsCategory record, String updateUser) {
		return goodsCategoryManager.update(record, updateUser);
	}

	@Override
	public void deleteCategory(GoodsCategory record, String updateUser) {
		goodsCategoryManager.delete(record, updateUser);
	}

	@Override
	public GoodsCategory getCategoryById(Integer categoryId) {
		return goodsCategoryManager.getById(categoryId);
	}

	@Override
	public List<GoodsCategory> queryCategoryByParentId(Integer parentCategoryId, Boolean isShow) {
		return goodsCategoryManager.queryByParentId(parentCategoryId, isShow);
	}

	@Override
	public Pagination<GoodsCategory> queryCategory(QueryGoodsCategoryDTO query, Sorting[] sorts, Page page) {
		return goodsCategoryManager.query(query, sorts, page);
	}

	@Override
	public GoodsCategory showCategory(GoodsCategory record, String updateUser) {
		return goodsCategoryManager.show(record, updateUser);
	}

	@Override
	public GoodsCategory hideCategory(GoodsCategory record, String updateUser) {
		return goodsCategoryManager.hide(record, updateUser);
	}

	@Autowired
	private GoodsAfterServiceManager goodsAfterServiceManager;

	@Override
	public GoodsAfterService addAfterService(GoodsAfterService record, String createUser) {
		return goodsAfterServiceManager.add(record, createUser);
	}

	@Override
	public GoodsAfterService editAfterService(GoodsAfterService record, String updateUser) {
		return goodsAfterServiceManager.edit(record, updateUser);
	}

	@Override
	public void deleteAfterService(GoodsAfterService record, String updateUser) {
		goodsAfterServiceManager.delete(record, updateUser);
	}

	@Override
	public GoodsAfterService getAfterServiceById(Integer afterServiceId) {
		return goodsAfterServiceManager.getById(afterServiceId);
	}

	@Override
	public Pagination<GoodsAfterService> queryAfterService(String name, Sorting[] sorts, Page page) {
		return goodsAfterServiceManager.query(name, sorts, page);
	}

	@Autowired
	private GoodsManager goodsManager;

	@Override
	public GoodsWithBLOBs addGoods(GoodsWithBLOBs record, List<String> shopwindowList, List<EditSpecGroupDTO> specGroup, String createUser) {
		return goodsManager.add(record, shopwindowList, specGroup, createUser);
	}

	@Override
	public GoodsWithBLOBs updateGoods(GoodsWithBLOBs record, List<String> shopwindowList, List<EditSpecGroupDTO> specGroup, String updateUser) {
		return goodsManager.update(record, shopwindowList, specGroup, updateUser);
	}

	@Override
	public void deleteGoods(GoodsWithBLOBs record, String updateUser) {
		goodsManager.delete(record, updateUser);
	}

	@Override
	public GoodsWithBLOBs getGoodsById(Integer goodsId) {
		return goodsManager.getById(goodsId);
	}

	@Override
	public Pagination<GoodsWithBLOBs> queryGoods(QueryGoodsDTO query, Sorting[] sorts, Page page) {
		return goodsManager.query(query, sorts, page);
	}

	@Autowired
	private GoodsShopwindowManager goodsShopwindowManager;

	@Override
	public List<GoodsShopwindow> queryGoodsShopwindowByGoodsId(Integer goodsId) {
		return goodsShopwindowManager.queryByGoodsId(goodsId);
	}

	@Autowired
	private GoodsSpecGroupManager goodsSpecGroupManager;

	@Override
	public List<GoodsSpecGroup> queryGoodsSpecGroupByGoodsId(Integer goodsId) {
		return goodsSpecGroupManager.queryByGoodsId(goodsId);
	}

	@Autowired
	private GoodsSpecManager goodsSpecManager;

	@Override
	public List<GoodsSpec> queryGoodsSpecByGroupId(Integer groupId) {
		return goodsSpecManager.queryByGroupId(groupId);
	}

	@Autowired
	private GoodsProductManager goodsProductManager;

	@Override
	public GoodsProduct getGoodsProductById(Integer productId) {
		return goodsProductManager.getById(productId);
	}

	@Override
	public List<GoodsProduct> queryGoodsProductByGoodsId(Integer goodsId) {
		return goodsProductManager.queryByGoodsId(goodsId);
	}

	@Override
	public GoodsProduct updateGoodsProduct(GoodsProduct product, List<String> barcodeList, String updateUser) {
		return goodsProductManager.update(product, barcodeList, updateUser);
	}

	@Override
	public Long sumStockNumberByGoodsId(Integer goodsId) {
		return goodsProductManager.sumStockNumberByGoodsId(goodsId);
	}

	@Override
	public Long sumUsedStockNumberByGoodsId(Integer goodsId) {
		return goodsProductManager.sumUsedStockNumberByGoodsId(goodsId);
	}

	@Override
	public Long sumSoldNumberByGoodsId(Integer goodsId) {
		return goodsProductManager.sumSoldNumberByGoodsId(goodsId);
	}

	@Autowired
	private GoodsBarcodeManager goodsBarcodeManager;

	@Override
	public List<GoodsBarcode> queryGoodsBarcodeByProductId(Integer productId) {
		return goodsBarcodeManager.queryByProductId(productId);
	}

	@Override
	public Pagination<GoodsCategory> queryGoodsCategoryForH5(Integer level, Integer parentCategoryId, Sorting[] sorts, Page page) {
		return goodsCategoryManager.queryForH5(level, parentCategoryId, sorts, page);
	}

	@Override
	public List<GoodsCategoryTopChildDO> queryGoodsCategoryTopChild(Integer minNumber, Integer size) {
		return goodsCategoryManager.queryCategoryTopChild(minNumber, size);
	}
	
	@Autowired
	private GoodsCategoryMarketingManager goodsCategoryMarketingManager;

	@Override
	public GoodsCategoryMarketing addGoodsCategoryMarketing(GoodsCategoryMarketing record, String createUser) throws BizException {
		return goodsCategoryMarketingManager.add(record, createUser);
	}

	@Override
	public GoodsCategoryMarketing editGoodsCategoryMarketing(GoodsCategoryMarketing record, String updateUser) throws BizException {
		return goodsCategoryMarketingManager.edit(record, updateUser);
	}

	@Override
	public void deleteGoodsCategoryMarketing(GoodsCategoryMarketing record, String updateUser) throws BizException {
		goodsCategoryMarketingManager.delete(record, updateUser);
	}

	@Override
	public GoodsCategoryMarketing getGoodsCategoryMarketing(Integer id) {
		return goodsCategoryMarketingManager.get(id);
	}

	@Override
	public Pagination<GoodsCategoryMarketing> goodsCategoryMarketingList(String name,Sorting[] sorts, Page page) {
		return goodsCategoryMarketingManager.query(name,sorts, page);
	}

	@Override
	public Pagination<GoodsCategoryMarketing> goodsCategoryMarketingListForH5(Page page) {
		return goodsCategoryMarketingManager.queryForH5(page);
	}

	@Override
	public GoodsCategoryMarketing getGoodsCategoryMarketingForH5(Integer id) {
		return goodsCategoryMarketingManager.getForH5(id);
	}

	@Override
	public GoodsCategoryMarketing getGoodsCategoryMarketingByCategoryId(Integer categoryId) {
		return goodsCategoryMarketingManager.getByCategoryId(categoryId);
	}

	@Autowired
	private DirectMailGoodsManager directMailGoodsManager;
	
	@Override
	public Long countDirectMailGoodsNumberByBrandId(Integer brandId) {
		return directMailGoodsManager.countDirectMailGoodsNumberByBrandId(brandId);
	}

}
